package calorie.com.calorie.contact;

import android.content.Context;

import com.lxh.baselibray.mvp.BasePresent;
import com.lxh.baselibray.mvp.IBaseView;
import com.lxh.baselibray.net.NetCallBack;
import com.lxh.baselibray.net.ServiceGenerator;
import com.lxh.baselibray.util.SPUtils;

import calorie.com.calorie.api.ApiService;
import calorie.com.calorie.constant.Constant;
import calorie.com.calorie.request.BaseRequest;
import calorie.com.calorie.request.BaseResponce;
import retrofit2.Call;
import retrofit2.Response;

public class SingleLoginContact {
    public static class SingleLoginPresent extends BasePresent<ISingleLoginView> {
        public void loginHeartbeat(Context context){
            String account = SPUtils.getString(Constant.ACCOUNT,"", context);
            String loginTime = SPUtils.getString(Constant.LOGIN_TIME,"", context);
            ApiService service = ServiceGenerator.createService(ApiService.class);
            BaseRequest request =  new BaseRequest();
            request.put("account",account);
            request.put("loginTime",loginTime);
            service.loginHeartbeat(request).enqueue(new NetCallBack<BaseResponce>() {
                @Override
                public void onSuccess(Call<BaseResponce> call, Response<BaseResponce> response) {
                    if (getView()!=null){
                        getView().loginHeartbeatResult(response);
                    }
                }

                @Override
                public void onFailed() {

                }
            });

        }

    }
    public interface ISingleLoginView extends IBaseView {
        void  loginHeartbeatResult(Response<BaseResponce> response);
    }
}
